package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.PermissionDao;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.Permission;
import com.itheima.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author LiangTianQi
 * @describe
 * @date 2020/11/23 15:40
 */
@Service(interfaceClass = PermissionService.class)
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private PermissionDao permissionDao;

    @Override
    public PageInfo getByConditions(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        List<Permission> permissionList=permissionDao.getByConditions(queryPageBean.getQueryString());
        PageInfo pageInfo = new PageInfo(permissionList);
        return pageInfo;
    }

    @Override
    @Transactional
    public void add(Permission permission) {
        permissionDao.add(permission);
    }

    @Override
    @Transactional
    public void delete(Integer id) {
        permissionDao.delete(id);
    }

    @Override
    @Transactional
    public void update(Permission permission) {
        permissionDao.update(permission);
    }

    @Override
    public Permission getById(Integer id) {
        Permission permission=permissionDao.getById(id);
        return permission;
    }
}
